主题
按类型获取公告 - GetAnnouncementsByType
函数简介
按公告类型获取公告列表。
返回数据格式:
json
{
"Code": 1,
"Message": "",
"TotalCount": 1,
"Items": [
{
"Guid": "a0b1c2d3",
"Title": "公告标题",
"Content": "公告正文",
"AnnouncementType": 1,
"AnnouncementTypeText": "系统公告",
"Priority": 1,
"PriorityText": "普通",
"IsPopup": true,
"IsTop": false,
"SortOrder": 10,
"PublishTime": "2026-04-20 08:00:00",
"ExpireTime": "2026-05-20 08:00:00",
"TargetUrl": "",
"IsRead": false
}
]
}| 字段名 | 类型 | 说明 |
|---|---|---|
| Code | 整数 | 结果状态码,通常 1 表示成功,0 或其他值表示失败。 |
| Message | 字符串 | 提示信息或错误信息,成功时通常为空字符串。 |
| TotalCount | 整数 | 总数量。 |
| Items | 数组 | 公告结果列表,每个元素为一个公告对象。 |
Items 元素字段说明:
| 字段名 | 类型 | 说明 |
|---|---|---|
| Guid | 字符串 | 公告唯一标识。 |
| Title | 字符串 | 公告标题。 |
| Content | 字符串 | 公告正文内容。 |
| AnnouncementType | 整数 | 公告类型编码。 |
| AnnouncementTypeText | 字符串 | 公告类型文本说明。 |
| Priority | 整数 | 优先级编码。 |
| PriorityText | 字符串 | 优先级文本说明。 |
| IsPopup | 布尔 | 是否弹窗展示。 |
| IsTop | 布尔 | 是否置顶。 |
| SortOrder | 整数 | 排序值,值越小越靠前。 |
| PublishTime | 字符串 | 公告发布时间。 |
| ExpireTime | 字符串 | 公告过期时间。 |
| TargetUrl | 字符串 | 公告关联跳转链接。 |
| IsRead | 布尔 | 当前用户是否已读。 |
接口名称
GetAnnouncementsByTypeDLL调用
long GetAnnouncementsByType(string userCode, string softCode, string softVersion, string dealerCode, int announcementType);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| userCode | 字符串 | 用户码。 |
| softCode | 字符串 | 软件码。 |
| softVersion | 字符串 | 软件版本。 |
| dealerCode | 字符串 | 经销商码。 |
| announcementType | 整数 | 公告类型。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
int ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0)vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0)text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.GetAnnouncementsByType(“value”, “value”, “value”, “value”, 0)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0)cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);原生 DLL 调用
cpp
long ptr = GetAnnouncementsByType(instance, "value", "value", "value", "value", 0);
if (ptr != 0) {
char buffer[512] = {0};
GetStringFromPtr(ptr, buffer, sizeof(buffer));
FreeStringPtr(ptr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GetAnnouncementsByType(string userCode, string softCode, string softVersion, string dealerCode, int announcementType);
long ptr = GetAnnouncementsByType(instance, "value", "value", "value", "value", 0);
if (ptr != 0) {
StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
GetStringFromPtr(ptr, sb, sb.Capacity);
FreeStringPtr(ptr);
string result = sb.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ptr = ola.GetAnnouncementsByType(instance, "value", "value", "value", "value", 0)
if ptr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(ptr, buf, 512)
ola.FreeStringPtr(ptr)
result = buf.value.decode("utf-8")返回值
成功返回 JSON 字符串格式的公告结果;失败返回 0。
注意事项
- 返回的字符串指针需要调用 FreeStringPtr 接口释放内存。
- 公告类型值请与服务端定义保持一致。
